package com.hksj.sglm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.base.query.BaseDeviceQuery;
import com.hksj.base.query.BaseSpecialityQuery;
import com.hksj.base.vo.AlarmRecordVO;
import com.hksj.base.vo.DeviceStatusVO;
import com.hksj.common.core.model.Rest;
import com.hksj.sglm.query.SpecialGasDailyAlarmQuery;
import com.hksj.sglm.query.SpecialGasDeviceQuery;
import com.hksj.sglm.service.SpecialGasAlarmService;
import com.hksj.sglm.vo.SpecialGasDailyAlarmNumVO;
import com.hksj.sglm.vo.SpecialGasDeviceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "特气泄漏-报警接口")
@RestController
@RequestMapping("/api/sglm/alarm")
public class SpecialGasAlarmController {
    @Autowired
    private SpecialGasAlarmService specialGasAlarmService;

    @ApiOperation(value = "大屏-分页查询当前报警记录列表")
    @PostMapping("/listCurrentAlarm")
    public Rest<List<AlarmRecordVO>> listCurrentAlarm(@RequestBody @Validated BaseSpecialityQuery query){
        List<AlarmRecordVO> list = specialGasAlarmService.listCurrentAlarm(query);
        return Rest.ok(list);
    }

    @ApiOperation("大屏-最近7天报警次数")
    @PostMapping("/listDailyAlarmNum")
    public Rest<List<SpecialGasDailyAlarmNumVO>> listDailyAlarmNum(@RequestBody SpecialGasDailyAlarmQuery query){
        List<SpecialGasDailyAlarmNumVO> list = specialGasAlarmService.listDailyAlarmNum(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "大屏-分页查询设备列表",response = SpecialGasDeviceVO.class)
    @PostMapping("/pageDevice")
    public Rest<Page<SpecialGasDeviceVO>> pageDevice(@RequestBody @Validated SpecialGasDeviceQuery query){
        Page<SpecialGasDeviceVO> page = specialGasAlarmService.pageDevice(query);
        return Rest.ok(page);
    }
}
